Lesson 3 - advanced exercise

Read the code in each section and do the following -

  1. Add comments to explain the code
  2. Suggest test data to test the code
  3. Make the suggested changes.

The following use a python library called turtle. You may need to install this manually. It is part of python-tk. If you get errors when running this code then that will be what is wrong.


from turtle import *

setup (width=200, height=200, startx=0, starty=0)


def square(x):
    for i in range(4):
        forward(x)
        right(90)

for i in range(20):
    square(10 + i)
    penup()
    right(20)
    forward(10+i)
    pendown()

done()


Suggested change - You are to create a work of art using the code above as well as help from the related link!